<?php
/**
 * 《外网地址》实现类
 *
 * @author 孙晓晔
 * @version $Id: Zone.class.php 804 2009-12-30 10:05:41Z sunxy $
 */
require_once(dirname(__FILE__) . '/InfoUtil.class.php');

class Qq extends InfoUtil {
	public $tbl = Constant::tbl_ip_qq;

	public $category = array(
		'-' => '请选择',
		'1' => 'QQ',		
		'2' => 'Qmail',

		'9' => '其它',
	);
	
	public $netmask = array(
		'-' => '请选择',
		'255.255.0.0' => '16',
		'255.255.255.0' => '24',
		'255.255.255.128' => '25',
		'255.255.255.192' => '26',
		'255.255.255.224' => '27',
		'255.255.255.240' => '28',
		'255.255.255.248' => '29',
		'255.255.255.252' => '30',
	);

	public $status = array(
		'-' => '请选择',
		'1' => '允许',
		'2' => '拒绝',
	
		'9' => '其它',
	);

	public $orderby = array(
		'-' => '请选择',
		'ip' => '地址',
		'1' => '创建时间',
		'2' => '更新时间',
	);

	function __construct() {
		$request['update'] = '$Date: 2009/02/16 07:36:07 $';
		$request['revision'] = '$Revision: 1.1 $';

		parent::__construct($request);
	}

	function pretreat($controller) {
		parent::pretreat($controller);

		$controller->assign_by_ref('netmask_option', $this->netmask);

		$controller->assign_by_ref('category_option', $this->category);
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function find($controller, $request) {
		$this->pretreat($controller);

		$province = $this->code_option('4');
		$controller->assign_by_ref('province_option', $province);

		$controller->display($request, 'info/qq/find');
		return true;
	}

	function _orderby_x($controller, $row, $px) {
		$orderby = $this->orderby['1'];
		$row['orderby_x'] = $row['createtime'];

		if (empty($px) || $px == '-' || $px == '1') {
			$controller->assign('orderby', $orderby);

			return $row;
		}

		if ($px == '2') {
			$orderby = $this->orderby[$px];
			$row['orderby_x'] = $row['modifytime'];
		}

		if ($px == 'mobile') {
			$orderby = $this->orderby[$px];
			$row['orderby_x'] = $row['mobile'];
		}

		$controller->assign('orderby', $orderby);

		return $row;
	}

	function _where($request) {
		$category_s = $request['category_s'];
		$ip_s = $request['ip_s'];
		
		$where = " WHERE 1=1";

		if (!empty($ip_s)) {
			$where .= " AND ip like '" . $ip_s . "%'";
		}
		
		if (!empty($category_s) && $category_s <> '-') {
			$where .= " AND category = '" . $category_s . "'";
		}

		$where .= $this->_where_default($request);
		$where = $this->_where_aa($where);

		return $where;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function findPost($controller, $request) {
		$this->pretreat($controller);

		$this->findPara($controller, $request);

		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s a %s %s";
		$where = $this->_where($request);
		$orderby = $this->_orderby();
		$sql = sprintf($fmt, $this->tbl, $where, $orderby);
		debug($sql);

		$pager_option = array (
            'db' => $db,
            'sql' => $sql,
            'PageSize' => $this->pagesize,
            'CurrentPageID' => $request['p'],
            'numItems' => $request['n']
		);

		$pager = @new Pager($pager_option);
		$data = $pager->getPageData();

		if ($pager->number > 0) {

			$count = 0;
			$from = $pager->from;
			while ($count < $pager->number) {
				$row = $data[$count];
				$row = $this->_view(null, $row);

				$row = $this->_orderby_x($controller, $row, $this->orderby_s);

				$data[$count] = $row;
				$count++;
			}
			$controller->assign_by_ref('result', $data);
			$controller->assign_by_ref('pager', $pager);
		}

		$controller->display($request, 'info/qq/list');
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function cal($controller, $request) {
		$this->pretreat($controller);

		$controller->display($request, 'info/qq/cal');
		return true;
	}

	function calPost($controller, $request) {
		$this->pretreat($controller);

		$ip = $request['ip'];
		$netmask = $request['netmask'];

		$ret = $this->_exist($ip, $netmask);
		if (is_array($ret)) {
			echo json_encode($ret);
			return true;
		}

		echo '不存在';
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function add($controller, $request) {
		$this->pretreat($controller);

		$controller->display($request, 'info/qq/add');
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function addPost($controller, $request) {
		$this->pretreat($controller);

		$ip = $request['ip'];
		$netmask = $request['netmask'];
		$category = $request['category'];

		$a = ip2long($netmask) & ip2long($ip);
		$content = sprintf("%s\n", long2ip($a), addslashes($request['content']));

		$status = $request['status'];

		clean($this->tbl . "_status_" . $status);

		$db = newdb($this->dsn_w);
		$fmt = "INSERT INTO %s(ip, netmask, category, content, status, createtime, modifytime)";
		$fmt .= " VALUES('%s', '%s', '%s', '%s', '%s', now(), now())";
		$sql = sprintf($fmt, $this->tbl, $ip, $netmask, $category, $content, $status);
		debug($sql);
		$db->query($sql);

		$request['id_s'] = $db->insert_id();
		
		$controller->assign('baseLink', $this->doGet($request, 'findPost'));

		$this->findPost($controller, $request);
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function edit($controller, $request) {
		$this->pretreat($controller);

		$id = $request['id'];

		clean($this->tbl . "_id_" . $id);
		$row = $this->id($this->tbl, $id);

		$controller->assign_by_ref('result', $row);

		$controller->display($request, 'info/qq/edit');
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function editPost($controller, $request) {
		$this->pretreat($controller);

		$id = $request['id'];
		clean($this->tbl . "_id_" . $id);

		$ip = $request['ip'];
		$netmask = $request['netmask'];
		$category = $request['category'];

		$a = ip2long($netmask) & ip2long($ip);
		$content = sprintf("%s\n", long2ip($a), addslashes($request['content']));

		$status = $request['status'];

		$db = newdb($this->dsn);
		$fmt = "UPDATE %s SET ip = '%s', netmask = '%s', category = '%s', content = '%s', status = '%s', modifytime = now() WHERE id = %s";
		$sql = sprintf($fmt, $this->tbl, $ip, $netmask, $category, $content, $status, $id);
		// debug($sql);
		$db->query($sql);
		if ($db->error()) {
			$controller->assign("msg", "修改失败，请联系管理员" . $db->error());
			$controller->display($request, 'info');
			return false;
		}

		$controller->assign('baseLink', $this->doGet($request, 'findPost'));

		$this->findPost($controller, $request);
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function copy($controller, $request) {
		$this->pretreat($controller);

		$id = $request['id'];

		clean($this->tbl . "_id_" . $id);
		$row = $this->id($this->tbl, $id);

		$controller->assign_by_ref('result', $row);

		$controller->display($request, 'info/qq/copy');
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function importPost($controller, $request) {
		$this->pretreat($controller);

		$data = $request['data'];
		// echo $data;

		$aa = preg_split("/[\\n]+/i", $data);
		// print_r($a);

		$province = '';
		$db = newdb($this->dsn);
		while (list($k, $v) = each($aa)) {
			$buf = trim($v);
			if (strlen($buf) < 5) {
				continue;
			}

			$a = preg_split("/[\t|\s]+/i", $buf);
			// print_r($a);
			if (count($a) < 2) {
				$province = $buf;
				continue;
			}

			$city = trim($a[0]);
			$zone = trim($a[1]);

			$fmt = "INSERT INTO %s(`province`, city, zone) VALUES('%s', '%s', '%s')";
			$sql = sprintf($fmt, $this->tbl, $province, $city, $zone);
			// debug($sql);
			$db->query($sql);
		}

		$controller->assign('baseLink', $this->doGet($request, 'findPost'));

		$this->findPost($controller, $request);
		return true;
	}

	/**
	 *
	 *
	 * @param Controller $controller
	 * @param array $request
	 */
	function view($controller, $request) {
		$this->pretreat($controller);

		$id = $request['id'];
		$row = $this->_view($id);

		$controller->assign_by_ref('result', $row);

		$controller->display($request, 'info/qq/view');
		return true;
	}
	
	function _view($id = 0, $row = null) {
		if ($row == null) {
			clean($this->tbl . "_id_" . $id);
			$row = $this->id($this->tbl, $id);
		}
		
		$row['category_t'] = $this->category[$row['category']];
		
		$row = $this->_view_t($row);

		return $row;
	}

	/**
	 *
	 *
	 * @param Controler $controller
	 * @param array $request
	 */
	function qq_sj($controller, $request) {
		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s WHERE category = '1' AND status = 2";
		$sql = sprintf($fmt, $this->tbl);
		// echo $sql . "\n";
		$result = $db->query($sql);
		$list = array();
		while ($row = $db->fetch_array($result)) {
			$s = $this->_ip($row['ip'], $row['netmask']);

			$fmt = "%s/%s";
			$cmd = sprintf($fmt, $s, $row['netmask']);
			$list[$s] = $cmd;
			// echo $cmd;
		}

		$rule = 'qq-output';

		$a = $this->_list($list);
		$this->_shell($a, $rule);

		$cmd = sprintf("/sbin/iptables -A %s -j ACCEPT\n", $rule);
		$this->_shell_exec($cmd);

		return true;
	}

	/**
	 *
	 *
	 * @param Controler $controller
	 * @param array $request
	 */
	function qq_ns($controller, $request) {
		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s WHERE category = '1' AND status = 2";
		$sql = sprintf($fmt, $this->tbl);
		// echo $sql . "\n";
		$result = $db->query($sql);
		$list = array();
		while ($row = $db->fetch_array($result)) {
			$s = $this->_ip($row['ip'], $row['netmask']);

			$fmt = "%s/%s";
			$cmd = sprintf($fmt, $s, $row['netmask']);
			$list[$s] = $cmd;
			// echo $cmd;
		}

		$rule = 'qq-output';

		$a = $this->_list($list);
		$this->_shell($a, $rule);

		return true;
	}
	
	function qmail($controller, $request) {
		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s WHERE category = '2' AND status = 2";
		$sql = sprintf($fmt, $this->tbl);
		echo $sql . "\n";
		$result = $db->query($sql);
		$list = array();
		while ($row = $db->fetch_array($result)) {
			$s = $this->_ip($row['ip'], $row['netmask']);

			$fmt = "%s/%s";
			$cmd = sprintf($fmt, $s, $row['netmask']);
			$list[$s] = $cmd;
			// echo $cmd;
		}

		$a = $this->_list($list);
		
		$rule = "INPUT";
		
		$cmd = sprintf("/sbin/iptables -F %s\n", $rule);
		// $this->_shell_exec($cmd);
		while (list($k, $v) = each($list)) {
			$fmt = "/sbin/iptables -I %s -s %s -j DROP\n";
			echo $cmd;
			$cmd = sprintf($fmt, $rule, $v);
			$this->_shell_exec($cmd);
		}

		return true;
	}

	function _shell_exec($cmd) {
		echo $cmd;
		shell_exec($cmd);
	}

	// 生成运行脚本
	function _shell($list, $rule) {
		$cmd = sprintf("/sbin/iptables -F %s\n", $rule);
		$this->_shell_exec($cmd);
		while (list($k, $v) = each($list)) {
			$fmt = "/sbin/iptables -A %s -d %s -j DROP\n";
			$cmd = sprintf($fmt, $rule, $v);
			$this->_shell_exec($cmd);
		}
	}
	
	function _insert($ip, $category, $status = '1') {
		if ($this->_is_insert($ip, $category, $status)) {
			echo "S";
			return false;
		}
		
		$db = newdb($this->dsn_w);
		$fmt = "INSERT INTO %s(ip, netmask, category, status, createtime) VALUES('%s', '%s', '%s', '%s', now())";
		$sql = sprintf($fmt, $this->tbl, $ip, '255.255.255.0', $category, $status);
		$db->query($sql);
		echo "I";
		
		return true;
	}
	
	
	function _is_insert($ip, $category, $status) {
		require_once APP_LIB . 'IpAddr.class.php';
		$ipaddr = new IpAddr();
		
		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s WHERE category = '%s'";
		$sql = sprintf($fmt, $this->tbl, $category);
		echo $sql . "\n";
		$result = $db->query($sql);
		$list = array();
		while ($row = $db->fetch_array($result)) {
			$s = $this->_ip($row['ip'], $row['netmask']);

			$fmt = "%s/%s";
			$range = sprintf($fmt, $s, $row['netmask']);
			// echo $range;
			
			if ($ipaddr->contains($range, $ip)) {
				return true;
			}
		}
		
		return false;
	}
	
	function day30($controller, $request) {
		$db = newdb($this->dsn_w);
		$fmt = "DELETE FROM %s WHERE category = '2' AND createtime < DATE_ADD(now(), INTERVAL -30 DAY)";
		$sql = sprintf($fmt, $this->tbl);
		$db->query($sql);
	
		logdate($controller, $request);
		return true;
	}

	// 排重
	function _list($list) {
		require_once APP_LIB . 'IpAddr.class.php';
		$ipaddr = new IpAddr();

		asort($list);

		$a = $list;
		$ret = array();
		while (list($k, $v) = each($list)) {
			if ($this->_contains($ipaddr, $a, $k)) {
				continue;
			}

			$ret[] = $v;
		}

		return $ret;
	}

	function _contains($ipaddr, $list, $ip) {
		reset($list);
		while (list($k, $v) = each($list)) {
			if ($k == $ip) {
				continue;
			}

			if ($ipaddr->contains($v, $ip)) {
				// echo sprintf("%s=%s\t%s\tS\n", $k, $v, $ip);
				return true;
			}
		}

		return false;
	}

	function _exist($ip, $netmask) {
		require_once APP_LIB . 'IpAddr.class.php';
		$ipaddr = new IpAddr();

		$db = newdb($this->dsn_r);
		$sql = sprintf("SELECT * FROM %s", $this->tbl);
		// echo $sql . "\n";
		$result = $db->query($sql);
		while ($row = $db->fetch_array($result)) {
			$s = $this->_ip($ip, $netmask);
			// echo $s . "\n";
			$range = sprintf("%s/%s", $row['ip'], $row['netmask']);

			if ($ipaddr->contains($range, $s)) {
				return $row;
			}
		}

		return false;
	}

	function b($controller, $request) {
		require_once APP_LIB . 'IpAddr.class.php';
		$ipaddr = new IpAddr();

		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s WHERE status = 2";
		$sql = sprintf($fmt, $this->tbl);
		// echo $sql . "\n";
		$result = $db->query($sql);
		$list = array();
		while ($row = $db->fetch_array($result)) {
			$s = $this->_ip($row['ip'], $row['netmask']);
			// echo $s . "\n";

			$fmt = "%s/%s";
			$cmd = sprintf($fmt, $s, $row['netmask']);
			$list[$s] = $cmd;
			// echo $cmd;
		}

		asort($list);
		// print_r($list);

		$a = $list;
		// print_r($a);

		$ret = array();
		while (list($k, $v) = each($a)) {
			if ($this->_contains($ipaddr, $a, $k)) {
				continue;
			}
			// echo sprintf("%s\n", $v);

			$ret[] = $v;
		}

		print_r($ret);

		echo "\n" . $_REQUEST['do'] . "\n";

		logdate($controller, $request);
		return true;
	}

	/**
	 *
	 *
	 * @param Controler $controller
	 * @param array $request
	 */
	function t($controller, $request) {
		$db = newdb($this->dsn_w);

		$file = "/home/sunxy/qq.txt";
		// $file = "d:/qq.txt";
		$fd = fopen($file, "r");
		while (!feof($fd)) {
			$buf = fgets($fd);
			// echo $buf;

			if (strlen($buf) < 5) {
				continue;
			}
			$a = preg_split("/[\\s,]+/", $buf);
			print_r($a);

			$b = preg_split("/[\/,]+/", $a[4]);
			print_r($b);

			$ip = $b[0];
			$netmask = $this->_mask($b[1]);

			$fmt = "INSERT INTO %s(ip, netmask, content, status, createtime, modifytime) VALUES('%s', '%s', '%s', '2', now(), now())";
			$sql = sprintf($fmt, $this->tbl, $ip, $netmask, $a[4]);
			// debug($sql);
			echo $sql . "\n";
			$db->query($sql);
		}
		fclose($fd);

		echo "\n" . $_REQUEST['do'] . "\n";

		logdate($controller, $request);
		return true;
	}

	function _mask($len) {
		$maskl = 0;

		for ($i = 0; $i < 31; $i++) {
			if ($i < $len) {
				$maskl = $maskl + pow(2, (31 - $i));
			}
		}

		return long2ip($maskl);
	}

	function _ip($ip, $mask) {
		$ret = ip2long($ip) & ip2long($mask);

		return long2ip($ret);
	}

	function z($controller, $request) {
		$ip = '121.14.101.169';
		$mask = '255.255.224.0';

		$a = ip2long($mask) & ip2long($ip);

		echo long2ip($a);

		logdate($controller, $request);
		return true;
	}
	
		function lookup($ip){
			//	if ($ip) {
			//	} else {
			//		$ip = gethostbyname($domain);
			//	}
	
			//返回Sina地理位置信息
			$json = @file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' . $ip);
			$patterns = array();
			$patterns[0] = '/var remote_ip_info = /';
			$patterns[1] = '/;/';
			$patterns[2] = '/\Wu/';
	
			$find = array();
			$find[0] = "";
			$find[1] = "";
			$find[2] = "%u";
	
			$json = preg_replace($patterns, $find, $json); //过滤多余字符
	
			return json_decode($json, true);
	}
	
	/**
	 * 获取客户端+服务端IP及地理位置信息 Sina iplookup
	 *
	 * @Support：QQ 910111100 (JoY)
	 * @Time: 2012.10.11 15:50:00
	 * @HZapi.com (http://www.hzapi.com/)
	 *
	 */
	function iplookup($ip=1){
		if ($ip) { //客户端
			$userip = egetip_joy(); //客户端IP
		} else { //服务端
			$domain = $_SERVER['HTTP_HOST'];
			$userip = gethostbyname($domain);
		}
	
		//返回Sina地理位置信息
		$json = @file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' . $userip);
		$patterns = array();
		$patterns[0] = '/var remote_ip_info = /';
		$patterns[1] = '/;/';
		$patterns[2] = '/\Wu/';
	
		$find = array();
		$find[0] = "";
		$find[1] = "";
		$find[2] = "%u";
	
		$json = preg_replace($patterns, $find, $json); //过滤多余字符
	
		return json_decode($json, true);
	}
	
	//取得IP
	function egetip_joy(){
		$a = getenv('HTTP_CLIENT_IP');
		$b = getenv('HTTP_X_FORWARDED_FOR');
		$c = getenv('REMOTE_ADDR');
		$d = $_SERVER['REMOTE_ADDR'];
		if ($a && strcasecmp($a,'unknown')) {
			$ip = $a;
		} elseif($b && strcasecmp($b,'unknown')) {
			$ip = $b;
		} elseif($c && strcasecmp($c,'unknown')) {
			$ip = $c;
		} elseif(isset($d) && $d && strcasecmp($d,'unknown')) {
			$ip  =$d;
		}
	
		return preg_replace("/^([d.]+).*/","1", $ip);
	}
	/**
	 * 模拟JS里的unescape
	 *
	 * @Support：QQ 910111100 (JoY)
	 * @Time: 2012.09.29 15:50:00
	 * @HZapi.com (http://www.hzapi.com/)
	 * echo unescape('%u4e1c%u6e56%u82b1%u56ed4%u53f7%u5c0f%u533a');
	 */
	function unescape($str) {
		$str = rawurldecode($str);
		preg_match_all("/(?:%u.{4})|.{4};|&#\d+;|.+/U",$str,$r);
		$ar = $r[0];
		foreach ($ar as $k => $v) {
			if (substr($v, 0, 2) == "%u") {
				$ar[$k] = iconv("UCS-2", "utf-8//IGNORE", pack("H4", substr($v, -4)));
			} elseif (substr($v, 0, 3) == "") {
				$ar[$k] = iconv("UCS-2", "utf-8", pack("H4", substr($v, 3, -1)));
			} elseif (substr($v, 0, 2) == "&#") {
				echo substr($v, 2, -1) . "";
				$ar[$k] = iconv("UCS-2", "utf-8", pack("n", substr($v, 2, -1)));
	        }
	    }
	    
	    return join("", $ar);
	}

	function f($controller, $request) {
		$domain = 'tecmold.com';
		$ip = gethostbyname($domain);
		$iplookup = $this->lookup($ip);
	  
	echo '返回状态：'.$iplookup['ret']."\n";
	echo 'IP范围Strat：'.$iplookup['start']."\n";
	echo 'IP范围End：'.$iplookup['end']."\n";
	
	echo '国家：'.unescape($iplookup['country'])."\n";
	echo '省份：'.unescape($iplookup['province'])."\n";
	echo '城市：'.unescape($iplookup['city'])."\n";
	echo '区/县：'.unescape($iplookup['district'])."\n";
	echo '线路：'.unescape($iplookup['isp'])."\n";
	
	echo '类型：'.$iplookup['type']."\n";
	echo '描写：'.$iplookup['desc']."<br>";

		logdate($controller, $request);
		return true;
	}

	function d($controller, $request) {
		$ip = '121.14.101.169';
		$mask = '255.255.224.0';
		$ret = $this->_exist($ip, $mask);
		if (is_array($ret)) {
			print_r($ret);
		} else {
			echo "222";
		}

		logdate($controller, $request);
		return true;
	}
	
	function message($controller, $request) {
		$db = newdb($this->dsn_w);

		$ret = array();
		$file = "/home/sunxy/messages";
		$fd = fopen($file, "r");
		while (!feof($fd)) {
			$buf = fgets($fd);
			// echo $buf;

			if (strlen($buf) < 5) {
				continue;
			}
			preg_match("/(qqIN=)(.*)(SRC=)(.*)(DST=)([\d|\\.]+)(.*)/", $buf, $m);
			// print_r($m);

			$fmt = "INSERT INTO %s(ip, netmask, content, status, createtime, modifytime) VALUES('%s', '%s', '%s', '2', now(), now())";
			// $sql = sprintf($fmt, $this->tbl, $ip, $netmask, $a[4]);
			// debug($sql);
			// echo $sql . "\n";
			// $db->query($sql);
			
			$src = $m[4];
			$dst = $m[6];
			if (preg_match("/^192.168.2/", $src)) {
				$ret[$src] = $dst;
			}
		}
		fclose($fd);
		
		print_r($ret);

		echo "\n" . $_REQUEST['do'] . "\n";

		logdate($controller, $request);
		return true;
	}
	
	function e($controller, $request) {
		$s = "Jan 17 10:17:09 ns kernel: qqIN=eth0 OUT=eth0 SRC=219.133.62.179 DST=192.168.2.98 LEN=283 TOS=0x00 PREC=0x00 TTL=56 ID=0 DF PROTO=UDP SPT=8000 DPT=4000 LEN=263";
		
		// preg_match("/(qqIN=)(.*)(SRC=)(.*)(DST=)(.*)(LEN=)(.*)/", $s, $m);
		preg_match("/(kernel: )(.*)(IN=)(.*)( SRC=)([\d|\\.]+)( DST=)([\d|\\.]+)( LEN=)(\d+)(.*)( PROTO=)(.*)( SPT=)(\d+)( DPT=)(\d+)/", $s, $m);
		
		print_r($m);
		
		echo "\n" . $_REQUEST['do'] . "\n";

		logdate($controller, $request);
		return true;
	}
	
}
?>